package org.rency.mq.kafka.consumer.support.listener;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.rency.mq.kafka.consumer.handler.MessageHandler;
import org.springframework.kafka.listener.MessageListener;

/**
 * Kafka消费者监听器
 *
 * @author: Created by user_rcy@163.com on 2016/10/21.
 * @version: V1.0.0
 * @since JDK 1.8
 */
public class KafkaMessageListener<K, V> implements MessageListener<K, V> {

    private MessageHandler<K, V> messageHandler;

    @Override
    public void onMessage(ConsumerRecord<K, V> data) {
        this.messageHandler.handler(data);
    }

    public void setMessageHandler(MessageHandler<K, V> messageHandler) {
        this.messageHandler = messageHandler;
    }
}
